using UnityEngine;
using System.Collections;

public class TransparenceBlinker : MonoBehaviour {

	// Use this for initialization
	void Start () 
	{
		StartCoroutine(AutoDestroyCoroutin(1.0f));
	}
	
	// Update is called once per frame
	void Update () 
	{
		if(renderer == null)
		{
			Destroy(this);
			return;
		}

		Color lMat = renderer.material.color;
		lMat.a = Mathf.PingPong(Time.time * 2, 1.0f);
		renderer.material.color = lMat;
	}
	
	public IEnumerator AutoDestroyCoroutin(float pSeconds)
	{
		yield return new WaitForSeconds(pSeconds);
		
		DestroyImmediate(this);
	}
}
